package Front_end;

import Back_end.Book;
import Back_end.BookManager;
import Back_end.SQL;

import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner input  =new Scanner(System.in);
        BookManager manager = new BookManager();
        int in;
        SQL.CreatTable();
        do{
            menu();
            in = input.nextInt();
            switch (in){
                case 1:
                    input.nextLine();
                    System.out.println("请输入LoginID");
                    String LoginID = input.nextLine();
                    System.out.println("请输入Name");
                    String Name = input.nextLine();
                    System.out.println("请输入Author");
                    String Author = input.nextLine();
                    System.out.println("请输入ClassCode");
                    String ClassCode = input.nextLine();
                    System.out.println("请输入PublicationUnit");
                    String PubilcationUnit = input.nextLine();
                    System.out.println("请输入PuvlicationTime");
                    String PublicationTime = input.nextLine();
                    System.out.println("请输入Price");
                    int price = input.nextInt();
                    manager.add(new Book(LoginID,Name,Author,ClassCode,PubilcationUnit,PublicationTime,price));
                    break;
                case 2:manager.show();break;
                case 3:
                    System.out.println("请输入想要搜索的书(请以书名或者作者名为索引)");
                    String flag = input.next();
                    manager.search(flag);break;
                case 4:System.out.println("请选择想要删除的书的LoginId");
                    String inp = input.nextLine();
                manager.delete(inp);
                break;
                case 5:
                    input.nextLine();
                    System.out.println("请输入LoginID");
                    String LoginID1 = input.nextLine();
                    System.out.println("请输入Name");
                    String Name1 = input.nextLine();
                    System.out.println("请输入Author");
                    String Author1 = input.nextLine();
                    System.out.println("请输入ClassCode");
                    String ClassCode1 = input.nextLine();
                    System.out.println("请输入PublicationUnit");
                    String PubilcationUnit1 = input.nextLine();
                    System.out.println("请输入PuvlicationTime");
                    String PublicationTime1 = input.nextLine();
                    System.out.println("请输入Price");
                    int price1 = input.nextInt();
                    manager.update(new Book(LoginID1,Name1,Author1,ClassCode1,PubilcationUnit1,PublicationTime1,price1));
                    break;
                case 6:
            }
        }while(in!=0);
    }
    public static void menu(){
        System.out.println("1.Add");
        System.out.println("2.Show");
        System.out.println("3.Search");
        System.out.println("4.Delete");
        System.out.println("5.Change");
        System.out.println("0.Exit");
    }
}
